import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/preview",
    name: "preview",
    component: () => import("../pages/preview/index.vue"),
  },
  {
    path: "/home",
    name: "home",
    component: () => import("../pages/home/index.vue"),
    children: [
      {
        path: "dataset",
        name: "dataset",
        component: () => import("../pages/home/components/dataset.vue"),
      },
      {
        path: "form",
        name: "form",
        component: () => import("../pages/home/components/form.vue"),
      },
      {
        path: "file",
        name: "file",
        component: () => import("../pages/home/components/storage/index.vue"),
      },
      {
        path: "setting",
        name: "setting",
        component: () => import("../pages/home/components/setting.vue"),
      },
      {
        path: "overview",
        name: "overview",
        component: () => import("../pages/home/components/overview.vue"),
      },
      {
        path: "personCenter",
        name: "personCenter",
        component: () => import("../pages/home/components/personCenter.vue"),
      },
      {
        path: "department",
        name: "department",
        component: () => import("../pages/home/components/department.vue"),
      },
      {
        path: "/form-detail",
        name: "form-detail",
        component: () => import("../pages/home/components/form-detail.vue"),
      },
      {
        path: "record-detail",
        name: "record-detail",
        component: () => import("../pages/home/components/record-detail.vue"),
      },
    ],
  },
  {
    path: "/editor",
    name: "editor",
    component: () => import("../pages/editor/index.vue"),
  },
  {
    path: "/form-editor",
    name: "form-editor",
    component: () => import("../pages/form-editor/index.vue"),
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../pages/login/index.vue"),
  },
  {
    path: "/viewer",
    name: "viewer",
    component: () => import("../pages/home/components/storage/file-detail.vue"),
  },
  {
    path: "/expand",
    name: "expand",
    component: () => import("../components/expand/expand.vue"),
  },
  {
    path: "/form-preview",
    name: "form-preview",
    component: () => import("../pages/form-preview/index.vue"),
  },
  {
    path: "/personCenter",
    redirect: "/home/personCenter",
  },
  {
    path: "/record-detail",
    redirect: "/home/record-detail",
  },
  {
    path: "/department",
    redirect: "/home/department",
  },
  {
    path: "/setting",
    redirect: "/home/setting",
  },
  {
    path: "/form-detail",
    redirect: "/home/form-detail",
  },
  {
    path: "/form",
    redirect: "/home/form",
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

// router.b;

export default router;
